
<?php
error_reporting('IGNORE_REPEATED_ERRORS');
$updated_ref = $_POST["updated_ref"];
$updated_value = $_POST["updated_value"];
?>

<HTML>
<HEAD>
<script type="text/javascript">
function update(index, value){
	if (isNaN(index)) {
		document.getElementById("config_manager").reset();
	}else{
		document.getElementById("config_manager").updated_ref.value = index;
		document.getElementById("config_manager").updated_value.value = value;
	}
}
</script>
</HEAD>
<BODY>
<FORM action="./config.php" method=POST name=config_manager id=config_manager>
<B>This form allows you to change system configuration options <U>one at a time</U>.</B><BR><BR>



<?php


mysql_connect("localhost", "root", "") or
    die("Could not connect: " . mysql_error());
mysql_select_db("QA");

if( (strlen($updated_ref)>0) && (strlen($updated_value)>0) ){
	mysql_query("update QA.Config SET Value=\"$updated_value\" where Reference_Number=\"$updated_ref\"");
	echo "<I>Updated config reference number ".$updated_ref." to a new value of ".$updated_value.".</I><BR><BR>";
}




$result = mysql_query("select Short_Description, Long_Description, Help_URL, Value, Reference_Number from QA.Config");
$short = Array();
$long = Array();
$URL = Array();
$value = Array();
$ref = Array();
$i = -1;
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
	$i = $i + 1;
	$short[$i] = $row[0];
	$long[$i] = $row[1];
	$URL[$i] = $row[2];
	$value[$i] = $row[3];
	$ref[$i] = $row[4];
}

mysql_free_result($result);


echo "<SCRIPT type=\"text/javascript\">\r\n<!--\r\n";
echo "var short = new Array();\r\n";
echo "var long = new Array();\r\n";
echo "var URL = new Array();\r\n";
echo "var value = new Array();\r\n";
echo "var ref = new Array();\r\n";
$j = 0;
while ($j<=$i){
	echo "short[$j] = \"$short[$j]\";\r\n";
	echo "long[$j] = \"$long[$j]\";\r\n";
	echo "URL[$j] = \"$URL[$j]\";\r\n";
	echo "value[$j] = \"$value[$j]\";\r\n";
	echo "ref[$j] = \"$ref[$j]\";\r\n";
	$j = $j+1;
}
echo "-->\r\n</SCRIPT>\r\n<BR>";


echo "Current Config Settings<BR>";
$i = 0;
echo "<OL>";
while($i<$j){
	echo "<LI><UL>";
	echo "<LI>Short Description: $short[$i]</LI>";
	echo "<LI>Long Description: $long[$i]</LI>";
	echo "<LI>Help URL: <A HREF=\"$URL[$i]\">$URL[$i]</A></LI>";
	echo "<LI>Configuration Value: <INPUT size=50 maxlength=254 name=value_$i id=value_$i value=\"$value[$i]\" onChange=\"javascript:update($ref[$i],this.value);\"/></LI>";
	echo "<LI>Reference Number: $ref[$i]</LI>";
	echo "</UL></LI>";
	$i++;
}
echo "</OL>";
?>
<INPUT type=hidden name=updated_ref id=updated_ref />
<INPUT type=hidden name=updated_value id=updated_value />
<INPUT type=SUBMIT name=SUBMIT value="Save Change" /><INPUT type=RESET name=RESET />
</FORM>
<BODY>
</HTML>